home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat2 / standard / fcntl.z / fcntl
Encoding:
Text File  |  2002-10-03  |  47.7 KB  |  858 lines

  1.  
  2.  
  3.  
  4. FFFFCCCCNNNNTTTTLLLL((((2222))))                                                              FFFFCCCCNNNNTTTTLLLL((((2222))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      fcntl - file and descriptor control
  10.  
  11. CCCC SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.      ####iiiinnnncccclllluuuuddddeeee <<<<uuuunnnniiiissssttttdddd....hhhh>>>>
  13.      ####iiiinnnncccclllluuuuddddeeee <<<<ffffccccnnnnttttllll....hhhh>>>>
  14.      iiiinnnntttt ffffccccnnnnttttllll ((((iiiinnnntttt ffffiiiillllddddeeeessss,,,, iiiinnnntttt ccccmmmmdddd,,,, ............ ////**** aaaarrrrgggg ****////))));;;;
  15.  
  16. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  17.      _f_c_n_t_l provides for control over open descriptors.  _f_i_l_d_e_s is an open
  18.      descriptor obtained from a _c_r_e_a_t, _o_p_e_n, _d_u_p, _f_c_n_t_l, _p_i_p_e, _s_o_c_k_e_t, or
  19.      _s_o_c_k_e_t_p_a_i_r system call.
  20.  
  21.      The commands available are:
  22.  
  23.      FFFF____DDDDUUUUPPPPFFFFDDDD   Return a new descriptor as follows:
  24.  
  25.                Lowest numbered available descriptor greater than or equal to
  26.                the third argument, _a_r_g, taken as an object of type int.
  27.  
  28.                Refers to the same object as the original descriptor.
  29.  
  30.                Same file pointer as the original file (i.e., both file
  31.                descriptors share one file pointer).
  32.  
  33.                Same access mode (read, write or read/write).
  34.  
  35.                Same descriptor status flags (i.e., both descriptors share the
  36.                same status flags).
  37.  
  38.                Shares any locks associated with the original file descriptor.
  39.  
  40.                The close-on-exec flag, FFFFDDDD____CCCCLLLLOOOOEEEEXXXXEEEECCCC associated with the new
  41.                descriptor is cleared to keep the file open across calls to the
  42.                _e_x_e_c(2) family of functions.
  43.  
  44.      FFFF____GGGGEEEETTTTFFFFDDDD   Get the file descriptor flags associated with the descriptor
  45.                _f_i_l_d_e_s.  If the FFFFDDDD____CCCCLLLLOOOOEEEEXXXXEEEECCCC flag is 0000 the descriptor will remain
  46.                open across _e_x_e_c, otherwise the descriptor will be closed upon
  47.                execution of _e_x_e_c.
  48.  
  49.      FFFF____SSSSEEEETTTTFFFFDDDD   Set the file descriptor flags for _f_i_l_d_e_s.  Currently the only
  50.                flag implemented is FFFFDDDD____CCCCLLLLOOOOEEEEXXXXEEEECCCC.  Note: this flag is a per-
  51.                process and per-descriptor flag; setting or clearing it for a
  52.                particular descriptor will not affect the flag on descriptors
  53.                copied from it by a _d_u_p(2) or FFFF____DDDDUUUUPPPPFFFFDDDD operation, nor will it
  54.                affect the flag on other processes instances of that
  55.                descriptor.
  56.  
  57.  
  58.  
  59.  
  60.  
  61.                                                                         PPPPaaaaggggeeee 1111
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68. FFFFCCCCNNNNTTTTLLLL((((2222))))                                                              FFFFCCCCNNNNTTTTLLLL((((2222))))
  69.  
  70.  
  71.  
  72.      FFFF____GGGGEEEETTTTFFFFLLLL   Get _f_i_l_e status flags and file access modes.  The file access
  73.                modes may be extracted from the return value using the mask
  74.                OOOO____AAAACCCCCCCCMMMMOOOODDDDEEEE.
  75.  
  76.      FFFF____SSSSEEEETTTTFFFFLLLL   Set _f_i_l_e status flags to the third argument, _a_r_g, taken as an
  77.                object of type int.  Only the following flags can be set [see
  78.                _f_c_n_t_l(5)]:  FFFFAAAAPPPPPPPPEEEENNNNDDDD, FFFFSSSSYYYYNNNNCCCC, DDDDSSSSYYYYNNNNCCCC, RRRRSSSSYYYYNNNNCCCC, FFFFNNNNDDDDEEEELLLLAAAAYYYY, FFFFNNNNOOOONNNNBBBBLLLLKKKK,
  79.                FFFFLLLLCCCCFFFFLLLLUUUUSSSSHHHH, FFFFLLLLCCCCIIIINNNNVVVVAAAALLLL, FFFFDDDDIIIIRRRREEEECCCCTTTT, and FFFFAAAASSSSYYYYNNNNCCCC.  Since _a_r_g is used as
  80.                a bit vector to set the flags, values for all the flags must be
  81.                specified in _a_r_g.  (Typically, _a_r_g may be constructed by
  82.                obtaining existing values by FFFF____GGGGEEEETTTTFFFFLLLL and then changing the
  83.                particular flags.)  FFFFAAAAPPPPPPPPEEEENNNNDDDD is equivalent to OOOO____AAAAPPPPPPPPEEEENNNNDDDD; FFFFSSSSYYYYNNNNCCCC is
  84.                equivalent to OOOO____SSSSYYYYNNNNCCCC; FFFFDDDDSSSSYYYYNNNNCCCC is equivalent to OOOO____DDDDSSSSYYYYNNNNCCCC; FFFFRRRRSSSSYYYYNNNNCCCC
  85.                is equivalent to OOOO____RRRRSSSSYYYYNNNNCCCC; FFFFNNNNDDDDEEEELLLLAAAAYYYY is equivalent to OOOO____NNNNDDDDEEEELLLLAAAAYYYY;
  86.                FFFFNNNNOOOONNNNBBBBLLLLKKKK is equivalent to OOOO____NNNNOOOONNNNBBBBLLLLOOOOCCCCKKKK; FFFFLLLLCCCCFFFFLLLLUUUUSSSSHHHH is equivalent to
  87.                OOOO____LLLLCCCCFFFFLLLLUUUUSSSSHHHH; FFFFLLLLCCCCIIIINNNNVVVVAAAALLLL is equivalent to OOOO____LLLLCCCCIIIINNNNVVVVAAAALLLL; and FFFFDDDDIIIIRRRREEEECCCCTTTT is
  88.                equivalent to OOOO____DDDDIIIIRRRREEEECCCCTTTT.  FFFFAAAASSSSYYYYNNNNCCCC is equivalent to calling _i_o_c_t_l
  89.                with the FFFFIIIIOOOOAAAASSSSYYYYNNNNCCCC command (except that with _i_o_c_t_l all flags
  90.                need not be specified).  This enables the SSSSIIIIGGGGIIIIOOOO facilities and
  91.                is currently supported only on sockets.
  92.  
  93.                Since the descriptor status flags are shared with descriptors
  94.                copied from a given descriptor by a _d_u_p(2) or FFFF____DDDDUUUUPPPPFFFFDDDD
  95.                operation, and by other processes instances of that descriptor
  96.                a FFFF____SSSSEEEETTTTFFFFLLLL operation will affect those other descriptors and
  97.                other instances of the given descriptors as well.  For example,
  98.                setting or clearing the FFFFNNNNDDDDEEEELLLLAAAAYYYY flag will logically cause an
  99.                FFFFIIIIOOOONNNNBBBBIIIIOOOO _i_o_c_t_l(2) to be performed on the object referred to by
  100.                that descriptor.  Thus all descriptors referring to that object
  101.                will be affected.
  102.  
  103.                Flags not understood for a particular descriptor are silently
  104.                ignored except for FFFFDDDDIIIIRRRREEEECCCCTTTT. FFFFDDDDIIIIRRRREEEECCCCTTTT will return _E_I_N_V_A_L if used
  105.                on other than an EFS, XFS or BDS file system file.
  106.  
  107.      FFFF____FFFFRRRREEEEEEEESSSSPPPP  Alter storage space associated with a section of the ordinary
  108.                file _f_i_l_d_e_s.  The section is specified by a variable of data
  109.                type _s_t_r_u_c_t _f_l_o_c_k pointed to by the third argument _a_r_g.  The
  110.                data type _s_t_r_u_c_t _f_l_o_c_k is defined in the <_f_c_n_t_l._h> header file
  111.                [see _f_c_n_t_l(5)] and contains the following members:  _l__w_h_e_n_c_e is
  112.                0, 1, or 2 to indicate that the relative offset _l__s_t_a_r_t will be
  113.                measured from the start of the file, the current position, or
  114.                the end of the file, respectively.  _l__s_t_a_r_t is the offset from
  115.                the position specified in _l__w_h_e_n_c_e.  _l__l_e_n is the size of the
  116.                section.  An _l__l_e_n of 0 frees up to the end of the file; in
  117.                this case, the end of file (i.e., file size) is set to the
  118.                beginning of the section freed.  Any data previously written
  119.                into this section is no longer accessible.  If the section
  120.                specified is beyond the current end of file, the file is grown
  121.                and filled with zeroes.  The _l__l_e_n field is currently ignored,
  122.                and should be set to 0.
  123.  
  124.  
  125.  
  126.  
  127.                                                                         PPPPaaaaggggeeee 2222
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134. FFFFCCCCNNNNTTTTLLLL((((2222))))                                                              FFFFCCCCNNNNTTTTLLLL((((2222))))
  135.  
  136.  
  137.  
  138.      FFFF____AAAALLLLLLLLOOOOCCCCSSSSPPPP This command is identical to FFFF____FFFFRRRREEEEEEEESSSSPPPP.
  139.  
  140.      FFFF____FFFFRRRREEEEEEEESSSSPPPP66664444
  141.                This command is identical to FFFF____FFFFRRRREEEEEEEESSSSPPPP except that the type of
  142.                the data referred to by the third argument _a_r_g is a _s_t_r_u_c_t
  143.                _f_l_o_c_k_6_4.  In this version of the structure, _l__s_t_a_r_t and _l__l_e_n
  144.                are of type ooooffffffff66664444____tttt instead of ooooffffffff____tttt (64 bits instead of 32
  145.                bits).
  146.  
  147.      FFFF____AAAALLLLLLLLOOOOCCCCSSSSPPPP66664444
  148.                This command is identical to FFFF____FFFFRRRREEEEEEEESSSSPPPP66664444.
  149.  
  150.      FFFF____FFFFSSSSSSSSEEEETTTTDDDDMMMM Set the _d_i__d_m_e_v_m_a_s_k and _d_i__d_m_s_t_a_t_e fields in an XFS on-disk
  151.                inode.  The only legitimate values for these fields are those
  152.                previously returned in the _b_s__d_m_e_v_m_a_s_k and _b_s__d_m_s_t_a_t_e fields of
  153.                the _b_u_l_k_s_t_a_t structure.  The data referred to by the third
  154.                argument _a_r_g is a _s_t_r_u_c_t _f_s_d_m_i_d_a_t_a.  This structure's members
  155.                are _f_s_d__d_m_e_v_m_a_s_k and _f_s_d__d_m_s_t_a_t_e.  The _d_i__d_m_e_v_m_a_s_k field is set
  156.                to the value in _f_s_d__d_m_e_v_m_a_s_k.  The _d_i__d_m_s_t_a_t_e field is set to
  157.                the value in _f_s_d__d_m_s_t_a_t_e.  This command is restricted to root
  158.                or to processes with device management capabilities.  Its sole
  159.                purpose is to allow backup and restore programs to restore the
  160.                aforementioned critical on-disk inode fields.
  161.  
  162.      FFFF____DDDDIIIIOOOOIIIINNNNFFFFOOOO Get information required to perform direct I/O on the specified
  163.                _f_i_l_d_e_s.  Direct I/O is performed directly to and from a user's
  164.                data buffer. Since the kernels buffer cache is no longer
  165.                between the two, the user's data buffer must conform to the
  166.                same type of constraints as required for accessing a raw disk
  167.                partition.  The third argument, _a_r_g, points to a data type
  168.                _s_t_r_u_c_t _d_i_o_a_t_t_r which is defined in the <_f_c_n_t_l._h> header file
  169.                and contains the following members: _d__m_e_m is the memory
  170.                alignment requirement of the user's data buffer. _d__m_i_n_i_o_s_z
  171.                specifies block size, minimum I/O request size, and I/O
  172.                alignment.  The size of all I/O requests must be a multiple of
  173.                this amount and the value of the seek pointer at the time of
  174.                the I/O request must also be an integer multiple of this
  175.                amount.  _d__m_a_x_i_o_s_z is the maximum I/O request size which can be
  176.                performed on the _f_i_l_d_e_s.  If an I/O request does not meet these
  177.                constraints, the _r_e_a_d(2) or _w_r_i_t_e(2) will return with _E_I_N_V_A_L.
  178.                All I/O requests are kept consistent with any data brought into
  179.                the cache with an access through a non-direct I/O file
  180.                descriptor.  See also FFFF____SSSSEEEETTTTFFFFLLLL above and _o_p_e_n (2).
  181.  
  182.      FFFF____GGGGEEEETTTTOOOOWWWWNNNN  Used by sockets: get the process ID or process group currently
  183.                receiving SSSSIIIIGGGGIIIIOOOO and SSSSIIIIGGGGUUUURRRRGGGG signals; process groups are returned
  184.                as negative values.
  185.  
  186.      FFFF____SSSSEEEETTTTOOOOWWWWNNNN  Used by sockets: set the process or process group to receive
  187.                SIGIO and SIGURG signals; process groups are specified by
  188.                supplying _a_r_g as negative, otherwise _a_r_g is interpreted as a
  189.                process ID.
  190.  
  191.  
  192.  
  193.                                                                         PPPPaaaaggggeeee 3333
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200. FFFFCCCCNNNNTTTTLLLL((((2222))))                                                              FFFFCCCCNNNNTTTTLLLL((((2222))))
  201.  
  202.  
  203.  
  204.      FFFF____FFFFSSSSGGGGEEEETTTTXXXXAAAATTTTTTTTRRRR
  205.                Get extended attributes associated with files in XFS file
  206.                systems.  The _a_r_g points to a variable of type _s_t_r_u_c_t _f_s_x_a_t_t_r.
  207.                The structure fields include:  _f_s_x__x_f_l_a_g_s (extended flag bits),
  208.                _f_s_x__e_x_t_s_i_z_e (nominal extent size in file system blocks),
  209.                _f_s_x__n_e_x_t_e_n_t_s (number of data extents in the file), _f_s_x__u_u_i_d
  210.                (file unique id).  Currently the only meaningful bits for the
  211.                _f_s_x__x_f_l_a_g_s field are bit 0 (value 1), which if set means the
  212.                file is a realtime file, and bit 1 (value 2), which if set
  213.                means the file has preallocated space.  A _f_s_x__e_x_t_s_i_z_e value
  214.                returned indicates that a preferred extent size was previously
  215.                set on the file, a _f_s_x__e_x_t_s_i_z_e of 0 indicates that the defaults
  216.                for that filesystem will be used.
  217.  
  218.      FFFF____FFFFSSSSGGGGEEEETTTTXXXXAAAATTTTTTTTRRRRAAAA
  219.                Identical to FFFF____FFFFSSSSGGGGEEEETTTTXXXXAAAATTTTTTTTRRRR except that the _f_s_x__n_e_x_t_e_n_t_s field
  220.                contains the number of attribute extents in the file.
  221.  
  222.      FFFF____FFFFSSSSSSSSEEEETTTTXXXXAAAATTTTTTTTRRRR
  223.                Set extended attributes associated with files in XFS file
  224.                systems.  The _a_r_g points to a variable of type _s_t_r_u_c_t _f_s_x_a_t_t_r,
  225.                but only the following fields are used in this call:
  226.                _f_s_x__x_f_l_a_g_s and _f_s_x__e_x_t_s_i_z_e.  The _f_s_x__x_f_l_a_g_s realtime file bit,
  227.                and the file's extent size, may be changed only when the file
  228.                is empty.
  229.  
  230.      FFFF____GGGGEEEETTTTBBBBMMMMAAAAPPPP Get the block map for a segment of a file in an XFS file
  231.                system.  The _a_r_g points to an array of variables of type _s_t_r_u_c_t
  232.                _g_e_t_b_m_a_p.  All sizes and offsets in the structure are in units
  233.                of 512 bytes.  The structure fields include:  _b_m_v__o_f_f_s_e_t (file
  234.                offset of segment), _b_m_v__b_l_o_c_k (starting block of segment),
  235.                _b_m_v__l_e_n_g_t_h (length of segment), _b_m_v__c_o_u_n_t (number of array
  236.                entries, including the first), and _b_m_v__e_n_t_r_i_e_s (number of
  237.                entries filled in).  The first structure in the array is a
  238.                header, and the remaining structures in the array contain block
  239.                map information on return.  The header controls iterative calls
  240.                to the FFFF____GGGGEEEETTTTBBBBMMMMAAAAPPPP command.  The caller fills in the _b_m_v__o_f_f_s_e_t
  241.                and _b_m_v__l_e_n_g_t_h fields of the header to indicate the area of
  242.                interest in the file, and fills in the _b_m_v__c_o_u_n_t field to
  243.                indicate the length of the array.  If the _b_m_v__l_e_n_g_t_h value is
  244.                set to -1 then the length of the interesting area is the rest
  245.                of the file.  On return from a call, the header is updated so
  246.                that the command can be used again to obtain more information,
  247.                without re-initializing the structures.  Also on return, the
  248.                _b_m_v__e_n_t_r_i_e_s field of the header is set to the number of array
  249.                entries actually filled in.  The non-header structures will be
  250.                filled in with _b_m_v__o_f_f_s_e_t, _b_m_v__b_l_o_c_k, and _b_m_v__l_e_n_g_t_h. If a
  251.                region of the file has no blocks (is a hole in the file) then
  252.                the _b_m_v__b_l_o_c_k field is set to -1.
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.                                                                         PPPPaaaaggggeeee 4444
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266. FFFFCCCCNNNNTTTTLLLL((((2222))))                                                              FFFFCCCCNNNNTTTTLLLL((((2222))))
  267.  
  268.  
  269.  
  270.      FFFF____GGGGEEEETTTTBBBBMMMMAAAAPPPPAAAA
  271.                Identical to FFFF____GGGGEEEETTTTBBBBMMMMAAAAPPPP except that information about the
  272.                attribute fork of the file is returned.
  273.  
  274.      FFFF____RRRREEEESSSSVVVVSSSSPPPP  This command is used to allocate space to a file.  A range of
  275.                bytes is specified with the _s_t_r_u_c_t _f_l_o_c_k.  The blocks are
  276.                allocated, but not zeroed, and the file size does not change.
  277.                It is only supported on XFS and BDS filesystems.  If the XFS
  278.                filesystem is configured to flag unwritten file extents,
  279.                performance will be negatively affected when writing to
  280.                preallocated space, since extra filesystem transactions are
  281.                required to convert extent flags on the range of the file
  282.                written.  If _x_f_s__g_r_o_w_f_s(1M) with the -n option reports
  283.                unwritten=1, then the filesystem was made to flag unwritten
  284.                extents.  Only the root user is permitted to execute
  285.                _x_f_s__g_r_o_w_f_s(1M).
  286.  
  287.      FFFF____RRRREEEESSSSVVVVSSSSPPPP66664444
  288.                This command is identical to FFFF____RRRREEEESSSSVVVVSSSSPPPP except that the type of
  289.                the data referred to by the third argument _a_r_g is a _s_t_r_u_c_t
  290.                _f_l_o_c_k_6_4.  In this version of the structure, _l__s_t_a_r_t and _l__l_e_n
  291.                are of type ooooffffffff66664444____tttt instead of ooooffffffff____tttt (64 bits instead of 32
  292.                bits).
  293.  
  294.      FFFF____UUUUNNNNRRRREEEESSSSVVVVSSSSPPPP
  295.                This command is used to free space from a file.  A range of
  296.                bytes is specified with the _s_t_r_u_c_t _f_l_o_c_k.  Partial filesystem
  297.                blocks are zeroed, and whole filesystem blocks are removed from
  298.                the file.  The file size does not change.  It is only supported
  299.                on XFS and BDS filesystems.
  300.  
  301.      FFFF____UUUUNNNNRRRREEEESSSSVVVVSSSSPPPP66664444
  302.                This command is identical to FFFF____UUUUNNNNRRRREEEESSSSVVVVSSSSPPPP except that the type of
  303.                the data referred to by the third argument _a_r_g is a _s_t_r_u_c_t
  304.                _f_l_o_c_k_6_4.  In this version of the structure, _l__s_t_a_r_t and _l__l_e_n
  305.                are of type ooooffffffff66664444____tttt instead of ooooffffffff____tttt (64 bits instead of 32
  306.                bits).
  307.  
  308.      FFFF____FFFFSSSSYYYYNNNNCCCC   fsync data in a range of an ordinary file _f_i_l_d_e_s.  The section
  309.                is specified by a variable of data type _s_t_r_u_c_t _f_l_o_c_k pointed to
  310.                by the third argument _a_r_g.  The data type _s_t_r_u_c_t _f_l_o_c_k is
  311.                defined in the <_f_c_n_t_l._h> header file [see _f_c_n_t_l(5)].  If field
  312.                _l__t_y_p_e is set to 1, the call behaves like fdatasync(2).  If
  313.                field _l__t_y_p_e is set to 0, the call behaves like fsync(2).
  314.                fdatasync(2) syncs only the inode state required to ensure that
  315.                the data is permanently on the disk.  fsync(2) syncs everything
  316.                that fdatasync(2) flushes but also syncs out the other state
  317.                associated with the file such as the current timestamps,
  318.                permissions, owner, etc.  _l__s_t_a_r_t specifies the start of the
  319.                range in the file to be sync'ed.  _l__l_e_n specifies the size of
  320.                the range.  A _l__l_e_n of 0 flushes everything up to the end of
  321.                the file.  The remaining fields are ignored and should be set
  322.  
  323.  
  324.  
  325.                                                                         PPPPaaaaggggeeee 5555
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332. FFFFCCCCNNNNTTTTLLLL((((2222))))                                                              FFFFCCCCNNNNTTTTLLLL((((2222))))
  333.  
  334.  
  335.  
  336.                to 0.
  337.  
  338.      FFFF____FFFFSSSSYYYYNNNNCCCC66664444 This command is identical to FFFF____FFFFSSSSYYYYNNNNCCCC except that the type of
  339.                the data referred to by the third argument _a_r_g is a _s_t_r_u_c_t
  340.                _f_l_o_c_k_6_4.  In this version of the structure, _l__s_t_a_r_t and _l__l_e_n
  341.                are of type ooooffffffff66664444____tttt instead of ooooffffffff____tttt (64 bits instead of 32
  342.                bits).
  343.  
  344.      FFFF____GGGGEEEETTTTBBBBIIIIOOOOSSSSIIIIZZZZEEEE
  345.                This command gets information about the preferred buffered I/O
  346.                size used by the system when performing buffered I/O (e.g.
  347.                standard Unix non-direct I/O) to and from the file.  The
  348.                information is passed back in a structure of type _s_t_r_u_c_t
  349.                _b_i_o_s_i_z_e pointed to by the third argument _a_r_g.  The data type
  350.                _s_t_r_u_c_t _b_i_o_s_i_z_e is defined in the <_f_c_n_t_l._h> header file [see
  351.                _f_c_n_t_l(5)].  biosize lengths are expressed in log base 2.  That
  352.                is if the value is 14, then the true size is 2^14 (2 raised to
  353.                the 14th power).  The biosz_read field will contain the current
  354.                value used by the system when reading from the file.  Except at
  355.                the end-of-file, the system will read from the file in
  356.                multiples of this length.  The biosz_write field will contain
  357.                the current value used by the system when writing to the file.
  358.                Except at the end-of-file, the system will write to the file in
  359.                multiples of this length.  The dfl_biosz_read and
  360.                dfl_biosz_write will be set to the system default values for
  361.                the opened file.  The biosz_flags field will be set to 1 if the
  362.                current read or write value has been explicitly set.  The
  363.                FFFF____GGGGEEEETTTTBBBBIIIIOOOOSSSSIIIIZZZZEEEE fcntl is supported only on XFS filesystems.
  364.  
  365.      FFFF____SSSSEEEETTTTBBBBIIIIOOOOSSSSIIIIZZZZEEEE
  366.                This command the preferred buffered I/O size used by the system
  367.                when performing buffered I/O (e.g. standard Unix non-direct
  368.                I/O) to and from the file.  The information is passed in a
  369.                structure of type _s_t_r_u_c_t _b_i_o_s_i_z_e pointed to by the third
  370.                argument _a_r_g.  Using smaller preferred I/O sizes can result in
  371.                performance improvements if the file is typically accessed
  372.                using small synchronous I/Os or if only a small amount of the
  373.                file is accessed using small random I/Os, resulting in little
  374.                or no use of the additional data read in near the random I/Os.
  375.  
  376.                To explicitly set the preferred I/O sizes, the biosz_flags
  377.                field should be set to 0 and the biosz_read and biosz_write
  378.                fields should be set to the log base 2 of the desired read and
  379.                write lengths, respectively (e.g. 13 for 8K bytes, 14 for 16K
  380.                bytes, 15 for 32K bytes, etc.).  Valid values are 13-16
  381.                inclusive for machines with a 4K byte pagesize and 14-16 for
  382.                machines with a 16K byte pagesize.  The specified read and
  383.                write values must also result in lengths that are greater than
  384.                or equal to the filesystem block size.  The dfl_biosz_read and
  385.                dfl_biosz_write fields are ignored.
  386.  
  387.                If biosizes have already been explicitly set due to a prior use
  388.  
  389.  
  390.  
  391.                                                                         PPPPaaaaggggeeee 6666
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398. FFFFCCCCNNNNTTTTLLLL((((2222))))                                                              FFFFCCCCNNNNTTTTLLLL((((2222))))
  399.  
  400.  
  401.  
  402.                of FFFF____SSSSEEEETTTTBBBBIIIIOOOOSSSSIIIIZZZZEEEE, and the requested sizes are larger then the
  403.                existing sizes, the fcntl call will return successfully and the
  404.                system will use the smaller of the two sizes.  However, if
  405.                biosz_flags is set to 1, the system will use the new values
  406.                regardless of whether the new sizes are larger or smaller than
  407.                the old.
  408.  
  409.                To reset the biosize values to the defaults for the filesystem
  410.                that the file resides in, the biosz_flags filed should be set
  411.                to 2.  The remainder of the fields will be ignored in that
  412.                case.
  413.  
  414.                Changes made by FFFF____SSSSEEEETTTTBBBBIIIIOOOOSSSSIIIIZZZZEEEE are transient.  The sizes are
  415.                reset to the default values once the reference count on the
  416.                file drops to zero (e.g. all open file descriptors to that file
  417.                have been closed).  See _f_s_t_a_b(4) for details on how to set the
  418.                default biosize values for a filesystem.  The FFFF____SSSSEEEETTTTBBBBIIIIOOOOSSSSIIIIZZZZEEEE
  419.                fcntl is supported only on XFS filesystems.
  420.  
  421.      The following commands are used for record-locking.  Locks may be placed
  422.      on an entire file or on segments of a file.
  423.  
  424.      FFFF____GGGGEEEETTTTLLLLKKKK   Get the first lock which blocks the lock description given by
  425.                the variable of type _s_t_r_u_c_t _f_l_o_c_k pointed to by _a_r_g.  The
  426.                information retrieved overwrites the information passed to
  427.                _f_c_n_t_l in the _f_l_o_c_k structure.  If no lock is found that would
  428.                prevent this lock from being created, then the structure is
  429.                passed back unchanged except that the lock type will be set to
  430.                FFFF____UUUUNNNNLLLLCCCCKKKK and the _l__w_h_e_n_c_e field will be set to SSSSEEEEEEEEKKKK____SSSSEEEETTTT.  If a
  431.                lock is found that would prevent this lock from being created,
  432.                then the structure is overwritten with a description of the
  433.                first lock that is preventing such a lock from being created.
  434.                The returned structure will also contain the process ID and the
  435.                system ID of the process holding the lock.  This command never
  436.                creates a lock; it tests whether a particular lock could be
  437.                created.
  438.  
  439.      FFFF____SSSSEEEETTTTLLLLKKKK   Set or clear a file segment lock according to the variable of
  440.                type _s_t_r_u_c_t _f_l_o_c_k pointed to by _a_r_g [see _f_c_n_t_l(5)].  The _c_m_d
  441.                FFFF____SSSSEEEETTTTLLLLKKKK is used to establish read (F_RDLCK) and write (F_WRLCK)
  442.                locks, as well as remove either type of lock (F_UNLCK).  If a
  443.                read or write lock cannot be set _f_c_n_t_l will return immediately
  444.                with an error value of -1.
  445.  
  446.      FFFF____SSSSEEEETTTTLLLLKKKKWWWW  This _c_m_d is the same as FFFF____SSSSEEEETTTTLLLLKKKK except that if a read or write
  447.                lock is blocked by other locks, the process will sleep until
  448.                the segment is free to be locked.
  449.  
  450.      FFFF____GGGGEEEETTTTLLLLKKKK66664444 This _c_m_d is identical to FFFF____GGGGEEEETTTTLLLLKKKK but uses a _s_t_r_u_c_t _f_l_o_c_k_6_4
  451.                instead of a _s_t_r_u_c_t _f_l_o_c_k (see FFFF____FFFFRRRREEEEEEEESSSSPPPP66664444 above).
  452.  
  453.  
  454.  
  455.  
  456.  
  457.                                                                         PPPPaaaaggggeeee 7777
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464. FFFFCCCCNNNNTTTTLLLL((((2222))))                                                              FFFFCCCCNNNNTTTTLLLL((((2222))))
  465.  
  466.  
  467.  
  468.      FFFF____SSSSEEEETTTTLLLLKKKK66664444 This _c_m_d is identical to FFFF____SSSSEEEETTTTLLLLKKKK but uses a _s_t_r_u_c_t _f_l_o_c_k_6_4
  469.                instead of a _s_t_r_u_c_t _f_l_o_c_k.
  470.  
  471.      FFFF____SSSSEEEETTTTLLLLKKKKWWWW66664444
  472.                This _c_m_d is identical to FFFF____SSSSEEEETTTTLLLLKKKKWWWW but uses a _s_t_r_u_c_t _f_l_o_c_k_6_4
  473.                instead of a _s_t_r_u_c_t _f_l_o_c_k.
  474.  
  475.      FFFF____SSSSEEEETTTTBBBBSSSSDDDDLLLLKKKK
  476.                This _c_m_d is identical to FFFF____SSSSEEEETTTTLLLLKKKK and provided for the backward
  477.                compatibility only. Newer applications should use FFFF____SSSSEEEETTTTLLLLKKKK
  478.                instead.
  479.  
  480.      FFFF____SSSSEEEETTTTBBBBSSSSDDDDLLLLKKKKWWWW
  481.                This _c_m_d is identical to FFFF____SSSSEEEETTTTLLLLKKKKWWWW and provided for the backward
  482.                compatibility only. Newer applications should use FFFF____SSSSEEEETTTTLLLLKKKKWWWW
  483.                instead.
  484.  
  485.      FFFF____RRRRSSSSEEEETTTTLLLLKKKK  Used  by the network lock daemon, _l_o_c_k_d(3N), to communicate
  486.                with the NFS server kernel to handle locks on NFS files.
  487.  
  488.      FFFF____RRRRSSSSEEEETTTTLLLLKKKKWWWW Used  by the network lock daemon, _l_o_c_k_d(3N), to communicate
  489.                with the NFS server kernel to handle locks on NFS files.
  490.  
  491.      FFFF____RRRRGGGGEEEETTTTLLLLKKKK  Used  by the network lock daemon, _l_o_c_k_d(3N), to communicate
  492.                with the NFS server kernel to handle locks on NFS files.
  493.  
  494.      FFFF____CCCCHHHHKKKKFFFFLLLL   This flag is used internally by FFFF____SSSSEEEETTTTFFFFLLLL to check the legality
  495.                of file flag changes.
  496.  
  497.      A read lock prevents any process from write locking the protected area.
  498.      More than one read lock may exist for a given segment of a file at a
  499.      given time.  The file descriptor on which a read lock is being placed
  500.      must have been opened with read access.
  501.  
  502.      A write lock prevents any process from read locking or write locking the
  503.      protected area.  Only one write lock and no read locks may exist for a
  504.      given segment of a file at a given time.  The file descriptor on which a
  505.      write lock is being placed must have been opened with write access.
  506.  
  507.      The structure _f_l_o_c_k describes the type (_l__t_y_p_e), starting offset
  508.      (_l__w_h_e_n_c_e), relative offset (_l__s_t_a_r_t), size (_l__l_e_n), process id (_l__p_i_d),
  509.      and system id (_l__s_y_s_i_d) of the segment of the file to be affected.  The
  510.      process id and system id fields are used only with the FFFF____GGGGEEEETTTTLLLLKKKK _c_m_d to
  511.      return the values for a blocking lock.  Locks may start and extend beyond
  512.      the current end of a file, but may not be negative relative to the
  513.      beginning of the file.  A lock may be set to always extend to the end of
  514.      file by setting _l__l_e_n to zero (0).  If such a lock also has _l__w_h_e_n_c_e and
  515.      _l__s_t_a_r_t set to zero (0), the whole file will be locked.  Changing or
  516.      unlocking a segment from the middle of a larger locked segment leaves two
  517.      smaller segments for either end.  Locking a segment that is already
  518.      locked by the calling process causes the old lock type to be removed and
  519.      the new lock type to take effect.  All locks associated with a file for a
  520.  
  521.  
  522.  
  523.                                                                         PPPPaaaaggggeeee 8888
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530. FFFFCCCCNNNNTTTTLLLL((((2222))))                                                              FFFFCCCCNNNNTTTTLLLL((((2222))))
  531.  
  532.  
  533.  
  534.      given process are removed when a file descriptor for that file is closed
  535.      by that process or the process holding that file descriptor terminates.
  536.      Locks are not inherited by a child process in a _f_o_r_k(2) system call.
  537.  
  538.      When file locking is used in conjunction with memory-mapped files over
  539.      NFS, the smallest locking granularity which will work properly with
  540.      multiple clients is the page size of the system.  All clients must use
  541.      the same granularity.
  542.  
  543.      When mandatory file and record locking is active on a file, [see
  544.      _c_h_m_o_d(2)], _r_e_a_d(_2), _c_r_e_a_t(_2), _o_p_e_n(_2), and _w_r_i_t_e(_2) system calls issued
  545.      on the file will be affected by the record locks in effect.
  546.  
  547.      The following commands are used for SMB opportunistic locks.  An SMB
  548.      server application will register oplocks on files and grant them to SMB
  549.      clients.  When external references are made to oplocked files, the SMB
  550.      server is notified to revoke the oplocks granted to clients before
  551.      operations from the external references are allowed to continue.
  552.  
  553.      FFFF____OOOOPPPPLLLLKKKKRRRREEEEGGGG The oplock registration command identifies the file to oplock
  554.                and, via _a_r_g, the write side of the pipe (e.g. p[1] from the
  555.                pipe(int *p) call) to use as the signaling mechanism.  The same
  556.                write side pipe can be used for any number of oplocked files.
  557.  
  558.                If any external references to the file already exist or the
  559.                caller already has an oplock on the file, the FFFF____OOOOPPPPLLLLKKKKRRRREEEEGGGG command
  560.                fails with _E_A_G_A_I_N.  If successful, the value of OOOOPPPP____EEEEXXXXCCCCLLLLUUUUSSSSIIIIVVVVEEEE is
  561.                returned.
  562.  
  563.      FFFF____OOOOPPPPLLLLKKKKSSSSTTTTAAAATTTT
  564.                The oplock state change command is used to get state change
  565.                information on any recently externally referenced files
  566.                registered with the given write side pipe (eg p[1] from a
  567.                pipe(int *p) call).  The returned _o_p_l_o_c_k__s_t_a_t__t structure
  568.                pointed at by _a_r_g contains the current state (_o_s__s_t_a_t_e) and the
  569.                dev/ino information (_o_s__d_e_v/_o_s__i_n_o) to identify the file.
  570.  
  571.                This is only done on the write side of a pipe for which
  572.                select() indicates there is a byte of data to read() on the
  573.                read side.  A byte of data must then be read() from the read
  574.                side of the pipe for each successful FFFF____OOOOPPPPLLLLKKKKSSSSTTTTAAAATTTT run on the
  575.                write side for select() to again give proper notification.
  576.  
  577.                External references that cause state change notification will
  578.                hang for a while until the SMB server acknowledges the
  579.                revocation (typically after revoking the oplock it granted to
  580.                the SMB client) or until the systunable oplock_timeout expires.
  581.  
  582.      FFFF____OOOOPPPPLLLLKKKKAAAACCCCKKKK The oplock acknowledgement command is primarily used to respond
  583.                to oplock state changes due to external references on the given
  584.                file.  The value given by _a_r_g can be OOOOPPPP____RRRREEEEVVVVOOOOKKKKEEEE to revoke the
  585.                oplock either voluntarily or as an acknowledgement of a state
  586.  
  587.  
  588.  
  589.                                                                         PPPPaaaaggggeeee 9999
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596. FFFFCCCCNNNNTTTTLLLL((((2222))))                                                              FFFFCCCCNNNNTTTTLLLL((((2222))))
  597.  
  598.  
  599.  
  600.                change reported in an FFFF____OOOOPPPPLLLLKKKKSSSSTTTTAAAATTTT command, or it can be -1 to
  601.                request the current state of the given file.
  602.  
  603.                If FFFF____OOOOPPPPLLLLKKKKAAAACCCCKKKK is not used to voluntarily revoke the oplock, the
  604.                oplock is automatically revoked on the SMB server's last
  605.                close() of the file.
  606.  
  607.                If FFFF____OOOOPPPPLLLLKKKKAAAACCCCKKKK is not used to revoke the oplock in response to a
  608.                state change indicated in an FFFF____OOOOPPPPLLLLKKKKSSSSTTTTAAAATTTT command, the oplock is
  609.                automatically revoked when the oplock_timeout expires.
  610.  
  611.      _f_c_n_t_l will fail if one or more of the following are true:
  612.  
  613.  
  614.      [EACCES]       _c_m_d is F_SETLK, the type of lock (_l__t_y_p_e) is a read lock (
  615.                     F_RDLCK, ) and the segment of a file to be lock is already
  616.                     write locked by another process, or the type is a write
  617.                     lock ( F_WRLOCK, ) and the segment of a file to be locked
  618.                     in already read or write locked by another process.
  619.  
  620.      [EBADF]        _F_i_l_d_e_s is not a valid open file descriptor.
  621.  
  622.      [EBADF]        _c_m_d is F_SETLK, or SETLKW, the type of lock (_l__t_y_p_e) is a
  623.                     read lock (F_RDLCK), and _f_i_l_d_e_s is not a valid file
  624.                     descriptor open for reading.
  625.  
  626.      [EBADF]        _c_m_d is F_SETLK, or SETLKW, the type of lock (_l__t_y_p_e) is a
  627.                     write lock (F_WRLCK), and _f_i_l_d_e_s is not a valid file
  628.                     descriptor open for writing.
  629.  
  630.      [EBADF]        _c_m_d is F_FREESP and _f_i_l_d_e_s is not a valid file descriptor
  631.                     open for writing.
  632.  
  633.      [EBADF]        _c_m_d is F_OPLOCKREG and the file is not a regular file or
  634.                     the _a_r_g is not the write side of a pipe.
  635.  
  636.      [EMFILE]       _c_m_d is F_DUPFD and {_O_P_E_N__M_A_X} file descriptors are
  637.                     currently in use by this process, or no file descriptors
  638.                     greater than or equal to _a_r_g are available.
  639.  
  640.      [EINVAL]       _c_m_d is F_DUPFD.  _a_r_g is either negative, or greater than
  641.                     or equal to the maximum number of open file descriptors
  642.                     allowed each user [see _g_e_t_d_t_a_b_l_e_s_i_z_e(2)].
  643.  
  644.      [EINVAL]       _c_m_d is F_GETLK, F_SETLK, or F_SETLKW and _a_r_g or the data
  645.                     it points to is not valid.
  646.  
  647.      [EINVAL]       _c_m_d is F_SETFL, _a_r_g includes _F_D_I_R_E_C_T and is being
  648.                     performed on other than an EFS, XFS or BDS file system
  649.                     file.
  650.  
  651.  
  652.  
  653.  
  654.  
  655.                                                                        PPPPaaaaggggeeee 11110000
  656.  
  657.  
  658.  
  659.  
  660.  
  661.  
  662. FFFFCCCCNNNNTTTTLLLL((((2222))))                                                              FFFFCCCCNNNNTTTTLLLL((((2222))))
  663.  
  664.  
  665.  
  666.      [EINVAL]       _c_m_d is F_SETBIOSIZE and _a_r_g is invalid.
  667.  
  668.      [EINVAL]       _c_m_d is F_OPLKREG and _f_i_l_d_e_s is a file in a filesystem
  669.                     other than XFS.  Kernel level oplocks are only supported
  670.                     for XFS.
  671.  
  672.      [EINVAL]       _c_m_d is F_OPLKACK and the _a_r_g is not OOOOPPPP____RRRREEEEVVVVOOOOKKKKEEEE or -1.
  673.  
  674.      [EAGAIN]       _c_m_d is F_FREESP , the file exists, mandatory file/record
  675.                     locking is set, and there are outstanding record locks on
  676.                     the file.  This restriction is not currently enforced.
  677.  
  678.      [EAGAIN]       _c_m_d is F_SETLK or F_SETLKW , mandatory file locking bit is
  679.                     set for the file, and the file is currently being mapped
  680.                     to virtual memory via _m_m_a_p [see _m_m_a_p(2)].  This
  681.                     restriction is not currently enforced.
  682.  
  683.      [EAGAIN]       _c_m_d is F_OPLKREG and there is more than one reference on
  684.                     the file.  Oplocks thus cannot be used to guarantee
  685.                     exclusive access to the file.
  686.  
  687.      [EAGAIN]       _c_m_d is F_OPLKSTAT and there are no state change messages
  688.                     for the specified write side pipe.
  689.  
  690.      [EPERM]        _c_m_d is F_OPLKREG or F_OPLKSTAT or F_OPLKACK and the user
  691.                     is not superuser.
  692.  
  693.      [ENOLCK]       _c_m_d is F_SETLK or F_SETLKW, the type of lock is a read or
  694.                     write lock, and there are no more record locks available
  695.                     (too many file segments locked) because the system maximum
  696.                     {_F_L_O_C_K__M_A_X} [see _i_n_t_r_o(2)], has been exceeded.  This can
  697.                     also occur if the object of the lock resides on a remote
  698.                     system and the requisite locking daemons are not
  699.                     configured in both the local and the remote systems.  In
  700.                     particular, if _llll_oooo_cccc_kkkk_dddd(1M) is running but _ssss_tttt_aaaa_tttt_dddd(1M) is not,
  701.                     this error will be returned.  An additional source for
  702.                     this error is when _ssss_tttt_aaaa_tttt_dddd(1M) is running but cannot be
  703.                     contacted.  This can occur when the address for the local
  704.                     host cannot be determined.  [See _llll_oooo_cccc_kkkk_dddd(1M) and _ssss_tttt_aaaa_tttt_dddd(1M).]
  705.  
  706.      [EINTR]        _c_m_d is F_SETLKW and a signal interrupted the process while
  707.                     it was waiting for the lock to be granted.
  708.  
  709.      [EDEADLK]      _c_m_d is F_SETLKW, the lock is blocked by some lock from
  710.                     another process, and putting the calling-process to sleep,
  711.                     waiting for that lock to become free, would cause a
  712.                     deadlock.
  713.  
  714.      [EDEADLK]      _c_m_d is F_FREESP, mandatory record locking is enabled,
  715.                     O_NDELAY and O_NONBLOCK are being clear and a deadlock
  716.                     condition was detected.
  717.  
  718.  
  719.  
  720.  
  721.                                                                        PPPPaaaaggggeeee 11111111
  722.  
  723.  
  724.  
  725.  
  726.  
  727.  
  728. FFFFCCCCNNNNTTTTLLLL((((2222))))                                                              FFFFCCCCNNNNTTTTLLLL((((2222))))
  729.  
  730.  
  731.  
  732.      [EFAULT]       _c_m_d is F_FREESP, and the value pointed to by the third
  733.                     argument _a_r_g resulted in an address outside the process's
  734.                     allocated address space.
  735.  
  736.      [EFAULT]       _c_m_d is F_GETLK, F_SETLK or F_SETLKW, and _a_r_g points
  737.                     outside the program address space.
  738.  
  739.      [ESRCH]        _c_m_d is F_SETOWN and no process can be found corresponding
  740.                     to that specified by _a_r_g.
  741.  
  742.      [EIO]          An I/O error occurred while reading from or writing to the
  743.                     file system.
  744.  
  745.      [EOVERFLOW]    _c_m_d is F_GETLK and the process ID of the process holding
  746.                     the requested lock is too large to be stored in the _l__p_i_d
  747.                     field.
  748.  
  749.      [ETIMEDOUT]    The object of the fcntl is located on a remote system
  750.                     which is not available [see _iiii_nnnn_tttt_rrrr_oooo(2)].
  751.  
  752. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  753.      lockd(1M), close(2), creat(2), dup(2), exec(2), fork(2),
  754.      getdtablesize(2), intro(2), open(2), pipe(2), fcntl(5).
  755.  
  756. DDDDIIIIAAAAGGGGNNNNOOOOSSSSTTTTIIIICCCCSSSS
  757.      Upon successful completion, the value returned depends on _c_m_d as follows:
  758.           F_DUPFD   A new file descriptor.
  759.           F_GETFD   Value of flag (only the low-order bit is defined).
  760.           F_SETFD   Value other than -1.
  761.           F_GETFL   Value of file flags.
  762.           F_SETFL   Value other than -1.
  763.           F_FREESP  Value of 0.
  764.           F_ALLOCSP Value of 0.
  765.           F_FREESP64
  766.                     Value of 0.
  767.           F_ALLOCSP64
  768.                     Value of 0.
  769.           F_DIOINFO Value of 0.
  770.           F_GETOWN  _p_i_d of socket owner.
  771.           F_SETOWN  Value other than -1.
  772.           F_FSGETXATTR
  773.                     Value of 0.
  774.           F_FSSETXATTR
  775.                     Value of 0.
  776.           F_GETBMAP Value of 0.
  777.           F_RESVSP  Value of 0.
  778.           F_RESVSP64
  779.                     Value of 0.
  780.           F_UNRESVSP
  781.                     Value of 0.
  782.  
  783.  
  784.  
  785.  
  786.  
  787.                                                                        PPPPaaaaggggeeee 11112222
  788.  
  789.  
  790.  
  791.  
  792.  
  793.  
  794. FFFFCCCCNNNNTTTTLLLL((((2222))))                                                              FFFFCCCCNNNNTTTTLLLL((((2222))))
  795.  
  796.  
  797.  
  798.           F_UNRESVSP64
  799.                     Value of 0.
  800.           F_GETLK   Value other than -1.
  801.           F_SETLK   Value other than -1.
  802.           F_SETLKW  Value other than -1.
  803.           F_GETLK64 Value other than -1.
  804.           F_SETLK64 Value other than -1.
  805.           F_SETLKW64
  806.                     Value other than -1.
  807.      Otherwise, a value of -1 is returned and _e_r_r_n_o is set to indicate the
  808.      error.
  809.  
  810.  
  811.  
  812.  
  813.  
  814.  
  815.  
  816.  
  817.  
  818.  
  819.  
  820.  
  821.  
  822.  
  823.  
  824.  
  825.  
  826.  
  827.  
  828.  
  829.  
  830.  
  831.  
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  
  840.  
  841.  
  842.  
  843.  
  844.  
  845.  
  846.  
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.                                                                        PPPPaaaaggggeeee 11113333
  854.  
  855.  
  856.  
  857.